<template>
   
  <div class="app-container">
    <el-card class="filter-container" shadow="never">
      <div>
        <i class="el-icon-search"></i>
        <span>筛选搜索</span>
        <el-button
          style="float: right"
          type="primary"
          @click="handleSearchList()"
          size="small"
        >
          查询搜索
        </el-button>
        <el-button
          style="float: right; margin-right: 15px"
          @click="handleResetSearch()"
          size="small"
        >
          重置
        </el-button>
      </div>
      <div style="margin-top: 15px">
        <el-form
          :inline="true"
          :model="listQuery"
          size="small"
          label-width="140px"
        >
          <el-form-item label="管理员ID：">
            <el-input
              v-model="listQuery.uuid"
              class="input-width"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="管理员昵称：">
            <el-input
              v-model="listQuery.nickname"
              class="input-width"
              placeholder="模糊查询"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="操作简介：">
            <el-input
              v-model="listQuery.operation"
              class="input-width"
              placeholder="模糊查询"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="操作人IP：">
            <el-input
              v-model="listQuery.ip"
              class="input-width"
              placeholder="模糊查询"
              clearable
            ></el-input>
          </el-form-item>
          <el-form-item label="起始时间：">
            <el-date-picker
              class="input-width"
              v-model="listQuery.startTime"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="请选择时间"
              clearable
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="截至时间：">
            <el-date-picker
              class="input-width"
              v-model="listQuery.endTime"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="请选择时间"
              clearable
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="响应时长超过：">
            <el-input
              v-model="listQuery.time"
              class="input-width"
              placeholder="请输入"
              clearable
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
    </el-card>
    <div class="table-container">
      <el-table
        ref="homeAdvertiseTable"
        :data="list"
        style="width: 100%"
        @selection-change="handleSelectionChange"
        v-loading="listLoading"
        border
        highlight-current-row
      >
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="请求参数">
                <span>{{ props.row.params }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="编号" width="100" align="center">
          <template slot-scope="scope">{{ scope.row.id }}</template>
        </el-table-column>
        <el-table-column label="管理员ID:" width="200" align="center">
          <template slot-scope="scope">{{ scope.row.uuid }}</template>
        </el-table-column>
        <el-table-column label="管理员昵称" width="100" align="center">
          <template slot-scope="scope">{{ scope.row.nickname }}</template>
        </el-table-column>
        <el-table-column label="操作简介" width="200" align="center">
          <template slot-scope="scope">{{ scope.row.operation }}</template>
        </el-table-column>
        <el-table-column label="请求方法名" align="center">
          <template slot-scope="scope">{{ scope.row.method }}</template>
        </el-table-column>

        <el-table-column label="响应时长" width="100" align="center">
          <template slot-scope="scope">{{ scope.row.time }}</template>
        </el-table-column>
        <el-table-column label="请求IP" width="120" align="center">
          <template slot-scope="scope">{{ scope.row.ip }}</template>
        </el-table-column>
        <el-table-column label="请求时间" width="170" align="center">
          <template slot-scope="scope">{{ scope.row.createDate }}</template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :page-size="listQuery.pageSize"
        :page-sizes="[5, 10, 15]"
        :current-page.sync="listQuery.pageNum"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { fetchList } from "@/api/adminlog";
const defaultListQuery = {
  pageNum: 1,
  pageSize: 5,
  uuid: null,
  nickname: "",
  endTime: null,
  startTime: null,
  ip: null,
  operation: null,
  time: null,
};
export default {
  name: "adminLogList",
  data() {
    return {
      listQuery: Object.assign({}, defaultListQuery),
      list: null,
      total: null,
      listLoading: false,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleResetSearch() {
      this.listQuery = Object.assign({}, defaultListQuery);
    },
    handleSearchList() {
      this.listQuery.pageNum = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.pageNum = 1;
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.getList();
    },
    getList() {
      this.listLoading = true;
      fetchList(this.listQuery).then((response) => {
        this.listLoading = false;
        this.list = response.data.list;
        this.total = response.data.total;
      });
    },
  },
};
</script>
<style scoped>
.input-width {
  width: 203px;
}
.demo-table-expand {
  font-size: 0;
}
/* .demo-table-expand label {
  width: 90px;
  color: #99a9bf;
} */
.demo-table-expand .el-form-item {
  margin-left: 100px;
  margin-bottom: 0;
  width: 50%;
}
</style>


